﻿using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TomShane.Neoforce.Controls;

namespace XGame.Class
{
    class ToolCell : Panel
    {
        const int width = 36;
        const int height = 36;
        Collection<ToolIcon.Type> iconTypes;
        ToolIcon icon;
        public ToolIcon Icon
        {
            get { return this.icon; }
            set
            {
                this.icon = value;
                if(this.icon != null)
                {
                    this.icon.Top = 0;
                    this.icon.Left = 0;
                    this.icon.SizeMode = SizeMode.Stretched;
                    this.icon.Width = this.Width;
                    this.icon.Height = this.Height;
                    this.icon.Parent = this;
                }
            }
        }

        public ToolCell(Manager Manager)
            : base(Manager)
        {
            this.Width = width;
            this.Height = height;
            iconTypes = new Collection<ToolIcon.Type>();
        }
        public ToolCell(Manager Manager, string text)
            : this(Manager)
        {
            this.Text = text;
        }
        public ToolCell(Manager Manager, string text, ToolIcon.Type[] types)
            : this(Manager, text)
        {
            for (int i = 0; i < types.Length; i++)
                iconTypes.Add(types[i]);
        }
        public ToolCell(Manager Manager, string text, ToolIcon.Type type)
            : this(Manager, text, new ToolIcon.Type[] { type })
        {
        }
        public ToolCell(Manager Manager, string text, ToolIcon.Type[] types, ToolIcon icon)
            : this(Manager, text, types)
        {
            this.Icon = icon;
        }
        public ToolCell(Manager Manager, string text, ToolIcon.Type type, ToolIcon icon)
            : this(Manager, text, new ToolIcon.Type[]{ type }, icon)
        {
        }
        public bool HasIcon()
        {
            return this.Icon != null;
        }
        public bool ContainType(ToolIcon.Type type)
        {
            return this.iconTypes.Contains(type);
        }
    }
}
